/**
 * 文件：BaseSQL.java
 * 说明：用于创建数据库链接实例
 * 作者：古通基
 * 时间：2011-09-13
 */

package com.java.component;

import java.sql.*;

public class BaseSQL
{
	Connection con = null;                            //链接接口
	Statement stmt = null;                            //语句对象
	ResultSet result =null;                             //结果集
	
	public BaseSQL() throws SQLException,ClassNotFoundException
	{
		Class.forName("com.mysql.jdbc.Driver");
		con = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+ConDataBasePanel.getDataBaseName(),ConDataBasePanel.getUser(),ConDataBasePanel.getPass());	
		stmt = con.createStatement();                                                       //语句对象
	}
	public ResultSet executeSelect(String sql) throws SQLException      //数据查询
	{
		result = null;                                                                                 //清空结果集
		result = stmt.executeQuery(sql);
		return result;
	}
	public void executeDML(String sql) throws SQLException              //数据操作
	{
		stmt.execute(sql);
	}
}